



//
//  NChangeNickNameViewController.m
//  nncloud
//
//  Created by macfai on 2018/11/9.
//  Copyright © 2018 youedata. All rights reserved.
//

#import "NChangeNickNameViewController.h"

@interface NChangeNickNameViewController ()

@property (weak, nonatomic) IBOutlet UITextField *nickNameTF;


@end

@implementation NChangeNickNameViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.navigationItem setItemWithTitle:@"修改昵称" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 40, 40) title:@"确定" Image:nil selectedIMG:nil tartget:self action:@selector(changeAction)];
    
    UIView *lineone = [[UIView alloc]initWithFrame:CGRectMake(0, 90, ScreenWidth, 0.5)];
//    UIView *linetwo = [[UIView alloc]initWithFrame:CGRectMake(0, 120, ScreenWidth, 0.5)];
//    UIView *linethree = [[UIView alloc]initWithFrame:CGRectMake(0, 173, ScreenWidth, 0.5)];
    lineone.backgroundColor = kLightGrayColor;
//    linethree.backgroundColor = kLightGrayColor;
//    linetwo.backgroundColor = kLightGrayColor;
    [self.view addSubview:lineone];
    // Do any additional setup after loading the view from its nib.
}

///确定按钮

- (void)changeAction {
    
    if (self.nickNameTF.text.length<0) {
        
         [AFToast showText:@"请填写信息"];
        
        return;
        
    }
    WeakStament(ws);
    
    NSDictionary *dic = @{@"userInfoId":[NUserModel shareInstance].userInfoId,@"userInfoNickname":self.nickNameTF.text};
    [NUserModel shareInstance].userInfoNickname = self.nickNameTF.text;
    
    [[NNRCNetRequest manager]postWithUrl:kChangeNickNameUrl params:dic success:^(id result) {
        
        
        YYLog(@"%@",result);
        if ([result[@"code"] integerValue]==0) {
            
            [AFToast showText:@"修改成功"];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [ws.navigationController popViewControllerAnimated:YES];
            });
            
        }else{
            [AFToast showText:result[@"msg"]];
        }
        
    } failure:^(id failure) {
        
         YYLog(@"%@",failure);
        
        
    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
